package com.e.maoyanapp2.utils;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitClient {
    private static RetrofitClient client;
    // 热映的url
    private static String BASE_URL1 = "https://wx.maoyan.com/mmdb/movie/v2/";
    // 即将上映,详情,查询url
    private static String BASE_URL2 = "https://m.maoyan.com/";

    public static synchronized RetrofitClient getInstance() {
        if (client == null) {
            client = new RetrofitClient();
        }
        return client;
    }

    public Retrofit getRetrofit(int type) {
        String url = type == 0 ? BASE_URL1 : BASE_URL2;
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit;
    }

}
